﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Reflection;
using System.Xml.XPath;
using MediaPortal.Profile;

namespace MyShowsPlugin
{
    class Settings
    {
        public static string login { get; set; }

        public static string password { get; set; }
        public static void Save()
        {
            MPSettings xmlwriter = new MPSettings();
            xmlwriter.SetValue("myshows", "login", login);
            xmlwriter.SetValue("myshows", "password", password);
            /**
            XmlDocument xmldoc = new XmlDocument();
            XmlDeclaration xmlDeclaration = xmldoc.CreateXmlDeclaration("1.0", "utf-8", null);
            XmlElement rootNode = xmldoc.CreateElement("myshows");
            xmldoc.InsertBefore(xmlDeclaration, xmldoc.DocumentElement);
            xmldoc.AppendChild(rootNode);
            xmldoc.Save("C://myshows.xml");
            XmlTextWriter writer = null;

            writer = new XmlTextWriter("C://myshows.xml", System.Text.Encoding.UTF8);
            writer.WriteStartDocument();
            writer.WriteStartElement("myshows");
            writer.WriteStartElement("login");
            writer.WriteName(login);
            writer.WriteEndElement();
            writer.WriteStartElement("hash");
            writer.WriteName(password);
            writer.WriteEndElement();
            writer.WriteEndElement();
            writer.WriteEndDocument();
            writer.Close();*/
        }
        public static void Load()
        {
            MPSettings xmlreader = new MPSettings();
            
                login = xmlreader.GetValueAsString("myshows", "login", "");
                password = xmlreader.GetValueAsString("myshows", "password", "");
                /**XmlDocument doc = new XmlDocument();
                doc.Load("C://myshows.xml");
                XmlNode node = doc.SelectSingleNode("/myshows/login");
                login = node.InnerText;
                XmlNode node1 = doc.SelectSingleNode("/myshows/hash");
                password = node1.InnerText*/


            
        }
    }
    }

